import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'LocalizationUtil.dart';

//语言国际化-系统语言适配代理
class LocalizationDelegate extends LocalizationsDelegate<LocalizationUtil>{

  const LocalizationDelegate();

  //支持中/英文
  @override
  bool isSupported(Locale locale) {
    return ['en','zh'].contains(locale.languageCode);
  }

  @override
  Future<LocalizationUtil> load(Locale locale) {
    return new SynchronousFuture<LocalizationUtil>(new LocalizationUtil(locale));
  }

  @override
  bool shouldReload(LocalizationsDelegate<LocalizationUtil> old) {
    return false;
  }

  static LocalizationDelegate delegate = const LocalizationDelegate();
}